package com.yuzou.十月马蹄杯;

import java.util.Scanner;

public class 数字串解谜 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        while (true) {
            int n = scanner.nextInt();
            if (n == 0) break;

            int[] signal = new int[n];
            for (int i = 0; i < n; i++) {
                signal[i] = scanner.nextInt();
            }

            // 解压过程
            int[] result = decompress(signal);

            // 输出结果
            for (int i = 0; i < result.length; i++) {
                if (i > 0) System.out.print(" ");
                System.out.print(result[i]);
            }
            System.out.println();
        }

        scanner.close();
    }
    private static int[] decompress(int[] compressed) {
        int n = compressed.length;
        int[] current = compressed.clone();

        // 从最内层开始向外解压
        for (int step = 1; step < n; step *= 2) {
            int[] temp = new int[n];

            for (int i = 0; i < step; i++) {
                // 根据和与差还原原始的两个数
                int sum = current[i];
                int diff = current[i + step];

                // a = (s + d) / 2, b = (s - d) / 2
                temp[2 * i] = (sum + diff) / 2;
                temp[2 * i + 1] = (sum - diff) / 2;
            }

            // 复制未处理的后半部分
            System.arraycopy(current, 2 * step, temp, 2 * step, n - 2 * step);
            current = temp;
        }

        return current;
    }
}
